// pages/search/search.js
var searchUrl = "https://m.douban.com/rexxar/api/v2/search?q=";
Page({
  data: {
    items: [],
  },
  onClickLeft() {
    wx.navigateBack({
      delta: 1,
    })
  },
  search({ detail }) {
    var that = this;
    wx.request({
      url: searchUrl + detail,
      success({ data }) {
       // console.log(data)
        that.setData({
          items: data.subjects.items
        })
      },
      fail() {
        wx.showToast({
          title: '没有该电影名字',
        })
      }
    })
  },

  onLoad: function (options) {
    var that = this;
    wx.request({
      url: searchUrl + options.value,
      success({ data }) {
        //console.log(data)
        that.setData({
          items: data.subjects.items
        })
      },
      fail() {
        wx.showToast({
          title: '没有该电影名字',
        })
      }
    })
  },
  tap({ currentTarget }) {
    wx.navigateTo({
      url: '/pages/appLetWork/work22/content/content?id=' + currentTarget.dataset.id + '&type=' + currentTarget.dataset.type,
    })
  }

})